package com.itheima.article;

import com.heima.article.ArticleApplication;
import com.heima.file.service.FileStorageService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

/**
 * @author mrchen
 * @date 2022/7/10 11:30
 */
@SpringBootTest(classes = ArticleApplication.class)
public class UploadMinIO {

    @Autowired
    @Qualifier("minIOFileStorageService")
    FileStorageService fileStorageService;

    @Value("${file.minio.readPath}")
    String readPath;

    /**
     * 将硬盘上的静态页list.html
     * 上传到minIO
      */
    @Test
    public void upload() throws FileNotFoundException {
        FileInputStream fileInputStream = new FileInputStream("C:\\work\\list.html");
        String minioPath = fileStorageService.store("test", "list.html", "text/html", fileInputStream);
        System.out.println(minioPath);

        System.out.println(readPath + minioPath);
    }
}
